<?php $this->load->view('common/head'); ?>

<?php $this->load->view('common/header'); ?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar'); ?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs'); ?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set'); ?>

                <div class="row">
                    <div class="col-xs-12">
                        <form accept-charset="UTF-8" id="new_add"
                              action="<?php echo site_url(X_URL . 'settings/settings'); ?>" class="form-horizontal"
                              role="form" method="post" novalidate="novalidate">
                            <?php echo csrf_hidden(); ?>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right">微信二维码</label>
                                <div class="col-sm-3 ace-file-input icon_upload" style="margin-left: 15px;">
                                    <input type="file" id="id-input-file">
                                    <span class="ace-file-container" data-title="Choose">
                                        <span class="ace-file-name" data-title="No File ...">
                                            <i class=" ace-icon fa fa-upload"></i>
                                        </span>
                                    </span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <?php if (isset($qrcode) && !empty($qrcode)) { ?>
                                <div class="form-group qrcode_box">
                                    <label class="col-sm-3 control-label no-padding-right"></label>
                                    <div class="col-sm-3" style="margin-left: 15px;">
                                        <img id="qrcode" width="200px"
                                             src="<?php echo $qrcode;?>"
                                             alt="">
                                    </div>
                                </div>
                            <?php } else { ?>
                                <div class="form-group qrcode_box" style="display: none">
                                    <label class="col-sm-3 control-label no-padding-right"></label>
                                    <div class="col-sm-3" style="margin-left: 15px;">
                                        <img id="qrcode" width="200px"
                                             src=""
                                             alt="">
                                    </div>
                                </div>
                            <?php } ?>

                            <input type="hidden" name="qrcode" id="qrcode_input" value="<?php echo $qrcode ?? ""?>">
                            <?php if (isset($vars) && !empty($vars)) { ?>
                                <?php foreach ($vars as $key => $val) { ?>
                                    <div class="space-4"></div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label no-padding-right"
                                               for="site_name"> <?php echo $val['name']; ?> </label>
                                        <?php if ($val['type'] == 1) { ?>
                                            <div class="col-sm-9">
                                                <input type="text" id="<?php echo $val['k']; ?>"
                                                       name="<?php echo $val['k']; ?>"
                                                       placeholder="<?php echo $val['name']; ?>"
                                                       class="col-xs-10 col-sm-5" value="<?php echo $val['v']; ?>">
                                                <span class="help-block col-sm-reset inline col-xs-12 col-sm-7 hidden-480"> 小时</span>
                                            </div>
                                        <?php } else { ?>
                                            <div class="col-sm-9">
                                                <textarea name="<?php echo $val['k']; ?>" id="<?php echo $val['k']; ?>"
                                                          placeholder="<?php echo $val['name']; ?>"
                                                          class="col-xs-10 col-sm-5"
                                                          rows="5"><?php echo $val['v']; ?></textarea>
                                            </div>
                                        <?php } ?>
                                    </div>
                                <?php } ?>
                            <?php } ?>
                            <div class="clearfix form-actions">
                                <div class="col-md-offset-3 col-md-9">
                                    <button class="btn btn-info" type="submit">
                                        <i class="ace-icon fa fa-check bigger-110"></i>
                                        确认更新
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer'); ?>
</div>

<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
</a>
<?php $this->load->view('common/footer');?>


<?php $this->load->view('common/footerjs');?>
<!-- ace scripts -->
<?php echo admin_js_url('jquery.core.image.upload.min'); ?>
<script>
    $(".ace-file-input").coreImageUpload({
        url: baseurl + 'index.php/upload/do_upload?name=file&type=setting',
        inputOfFile: 'file',
        uploadedCallback: function (result) {
            if (result.status == 1) {
                $("#qrcode").attr("src", result.url);
                $("#qrcode_input").val(result.url);
                $(".qrcode_box").show();
            } else {
                console.log(result.msg);
                alert("error");
            }
        }
    });
</script>
<!-- inline scripts related to this page -->
</body>
</html>